Skip to content

Lazy connect to config_db during first collect instead of during init#406

Merged
hdwhdw merged 2 commits into
sonic-net:masterfrom
tirupatihemanth:fix_debug_info_pub
Jul 10, 2026
Merged

Lazy connect to config_db during first collect instead of during init#406
hdwhdw merged 2 commits into
sonic-net:masterfrom
tirupatihemanth:fix_debug_info_pub

Conversation

@tirupatihemanth

@tirupatihemanth tirupatihemanth commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Why I did it

Avoid reading CONFIG_DB when sonic-hostservice initializes. On DPU boot, the host service can start before database files are ready, causing a transient parseDatabaseConfig error even though artifact collection is not requested yet.

Observed log:

2026 Jul  7 09:27:01.087175 sonic INFO systemd[1]: Started sonic-hostservice.service - SONiC Host Service.
2026 Jul  7 09:27:01.092005 sonic ERR python3: :- parseDatabaseConfig: Sonic database config file doesn't exist at /var/run/redis/sonic-db/database_config.json
2026 Jul  7 09:27:01.095411 sonic INFO python3[1218]: Failed to read hostname/board_type from CONFIG_DB: Sonic database config file doesn't exist at /var/run/redis/sonic-db/database_config.json
2026 Jul  7 09:27:08.163389 sonic INFO systemd[1]: Starting database.service - Database container...
Work item tracking
  • Microsoft ADO (number only): N/A

How I did it

  • Initialize debug artifact metadata with safe defaults in DebugArtifactCollector.__init__.
  • Keep CONFIG_DB metadata lookup lazy during the first collect() call.
  • Add a unit test to ensure constructor initialization does not read device metadata.

How to verify it

  • Run tests/debug_info_test.py.
  • Restart sonic-hostservice before database readiness and verify init emits no parseDatabaseConfig error.

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202305
  • 202311
  • 202405
  • 202411
  • 202605

Reason: fixes a DPU boot-time false error log.

Tested branch (Please provide the tested image version)

  • 202605
  • master

Description for the changelog

Lazy connect to config_db during first collect instead of during init

Signed-off-by: Hemanth Kumar Tirupati <htirupati@nvidia.com>
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@hdwhdw
hdwhdw self-requested a review July 9, 2026 19:21

@hdwhdw hdwhdw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just confirmed it safe since this is the default value the collect function as well. But I'll recommend creating a constant for it so we know this is the default value and not some random string.

Signed-off-by: Hemanth Kumar Tirupati <htirupati@nvidia.com>
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@tirupatihemanth

Copy link
Copy Markdown
Contributor Author

@hdwhdw thanks for the review. Addressed the concern in the new revision. Please take a look.

@tirupatihemanth
tirupatihemanth requested a review from hdwhdw July 10, 2026 16:34
@hdwhdw
hdwhdw merged commit 5a071f0 into sonic-net:master Jul 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants